﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using GraphicsLib;
using TowerDefence.Entities.States;

namespace TowerDefence.Tiles
{
    public class PathTile : Tile
    {      
        private Dictionary<eAIPath, eAIDir> aiPathDirections;        

        public PathTile(Vector2 _position, Dictionary<eAIPath, eAIDir> _directions) : base(_position)
        {
            aiPathDirections = _directions;
        }

        public void SetDirectionForPath(eAIPath _path, eAIDir _dir)
        {
            this.aiPathDirections.Add(_path, _dir);
        }

        public eAIDir GetDirectionForPath(eAIPath _path)
        {
            return this.aiPathDirections[_path];
        }

        public override void DebugDraw(Graphics2D _graphics)
        {
            // draw directions
            foreach (var dir in this.aiPathDirections)
            {
                Vector2 pos = Vector2.Zero;
                Color col = Color.Black;
                int offset = 15;
                int size = 5;
                var posAsVec = new Vector2(this.Position.X, this.Position.Y);
                switch (dir.Key)
                {                   
                    case eAIPath.BLUE:
                        col = Color.Blue;
                        pos = posAsVec;
                        break;
                    case eAIPath.GREEN:
                        col = Color.DarkGreen;
                        pos = posAsVec + new Vector2(offset, 0);
                        break;
                    case eAIPath.RED:
                        col = Color.Red;
                        pos = posAsVec + new Vector2(0, offset);
                        break;
                    case eAIPath.PURPLE:
                        col = Color.Purple;
                        pos = posAsVec + new Vector2(offset, offset);
                        break;
                }
                _graphics.DrawRectangle(pos, size, size, col);
            }
        }
    }
}
